<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table id="abc" border="1"></table>
<input type="button" value="添加行" onclick="addNew()"/>
<input type="button" value="删除行" onclick="del()"/>
<script>
var bq=document.getElementById("abc");
for(var i=0;i<3;i++){
	var tr=document.createElement("tr");
	for(var j=0;j<3;j++){
		var td=document.createElement("td");
		td.style.height="30px";
		td.style.width="30px";
		tr.appendChild(td);
		}
	bq.appendChild(tr);
	}
function addNew(){
	var tr=bq.lastChild.cloneNode(true);
	bq.appendChild(tr);
	
	
	}
function del(){
	if(bq.children.length==1){
		alert("最后一个了，手下留情吧");
	
		}
	else{
		bq.removeChild(bq.lastChild);
	}
	
	}





</script>
</body>
</html>
